﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynaPrecision.LinearSystem
{
	public class ReverseIndexedMultidimensionalArray<TWrappedArray, TData> : IMultiDimensionalArray<TData>
		where TWrappedArray : IMultiDimensionalArray<TData>
	{

		public ReverseIndexedMultidimensionalArray()
		{
		}
		public ReverseIndexedMultidimensionalArray(TWrappedArray wrappedArray)
		{
			this.WrappedArray = wrappedArray;
		}
		public TWrappedArray WrappedArray
		{
			get;
			set;
		}

		#region IMultiDimensionalArray<TInput> Members

		public TData this[params int[] index]
		{
			get
			{
				return WrappedArray[index.Reverse().ToArray()];
			}
			set
			{
				WrappedArray[index.Reverse().ToArray()] = value;
			}
		}

		public int GetLength(int DimensinNumber)
		{
			return this.WrappedArray.GetLength(Dimension - DimensinNumber - 1);
		}

		public int Dimension
		{
			get
			{
				return WrappedArray.Dimension;
			}
		}

		#endregion
	}
}
